using System;
using System.Collections.Generic;
using System.Text;
using DatabaseCode.Data;

namespace DatabaseCode
{
  class Debug
  {
    public static string HierarchyString(D1_Headers headers)
    {
      string str = "";
      str += "ヘッダー件数" + headers.Headers.Count + "\r\n\r\n";
      foreach (D2_Header h in headers.Headers)
      {
        str += "マネージャ名：" + h.Name + "\r\n";
        str += "テーブル数：" + h.Tables.Count + "\r\n";
        foreach (D3_Table t in h.Tables)
        {
          str += "  テーブル名：" + t.Name + "\r\n";
          str += "  コメント：" + t.Comment + "\r\n";
          foreach (D4_Field f in t.Fields)
          {
            str += "    型名：" + f.Typename + "\r\n";
            str += "    変数名：" + f.Variablename + "\r\n";
            str += "    コメント：" + f.Comment + "\r\n";
            if (f.IsPrimarykey)
            {
              str += "      主キー\r\n";
            }
            if (f.HasReference)
            {
              str += "      参照：" + f.RefTable + "." + f.RefMember + "\r\n";
            }
          }
        }
      }
      return str;
    }

    public static void ResetMessage()
    {
      m_message = "";
    }
    public static void AddMessageLine(string str)
    {
      AddMessage(str + "\r\n");
    }

    public static void AddMessage(string str)
    {
      m_message += str;
    }
    public static string Message
    {
      get
      {
        return m_message;
      }
    }

    private static string m_message = "";
  }
}
